package com.khyr.controller;

import com.khyr.utils.DemoUtil;
import com.khyr.vo.R;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author ：lyk
 * @date ：Created in 2025/3/13 14:31
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/inspect/img")
public class UploadPictures {
    @PostMapping("/upload")
    public R<String> upload(MultipartFile file){
        String url = null;
        try {
            url = DemoUtil.upload(file);
        } catch (Exception e) {
            return new R(400,"上传失败",null);
        }
        return new R(200,"上传成功",url);
    }
    @GetMapping("/delete")
    public R<String> delete(String url){
        try {
            DemoUtil.delete(url);
        } catch (Exception e) {
            return new R(400,"删除失败",null);
        }
        return new R(200,"删除成功",null);
    }
}
